import type { PageParams, PageResult } from '@/types/global'
import type { BannerItem, CategoryItem, GuessItem, HotItem, NewItem } from '@/types/home'
import { http } from '@/utils/http'

/**
 * 首页-广告区域
 * @param distributionSite 说明：广告区域展示位置（投放位置 投放位置，1为首页，2为分类商品页） 默认是1
 */
export const getHomeBannerAPI = (distributionSite = 1) => {
  return http<BannerItem[]>({
    method: 'GET',
    url: '/home/banner',
    data: {
      distributionSite: distributionSite,
    },
  })
}

/**
 * 首页-前台类目-小程序
 */
export const getHomeCategoryHeadMutliAPI = () => {
  return http<CategoryItem[]>({
    method: 'GET',
    url: '/home/category/head/mutli',
  })
}

/**
 * 首页-人气推荐-小程序和app
 */
export const getHomeHotAPI = () => {
  return http<HotItem[]>({
    method: 'GET',
    url: '/home/hot/mutli',
  })
}

/**
 * 首页-新鲜好物-pc-小程序
 * @param limit 说明：默认值为 4，指定响应数据中商品的数量
 */
export const getHomeNewAPI = (limit = 4) => {
  return http<NewItem[]>({
    method: 'GET',
    url: '/home/new',
    data: {
      limit: limit,
    },
  })
}

/**
 * 猜你喜欢-小程序
 * @param data 通用分页参数
 */
export const getHomeGoodsGuessLikeAPI = (data?: PageParams) => {
  return http<PageResult<GuessItem>>({
    method: 'GET',
    url: '/home/goods/guessLike',
    data,
  })
}
